{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import json\n",
    "from keras.models import Model\n",
    "from keras.layers import Input\n",
    "from keras.layers import Conv2D, MaxPooling2D, AveragePooling2D, BatchNormalization, merge\n",
    "from keras import backend as K"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def format_decimal(arr, places=8):\n",
    "    return [round(x * 10**places) / 10**places for x in arr]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### pipeline 18"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'weights': [{'shape': [1, 1, 2, 2], 'data': [-0.71596766, 0.83019575, 0.12233745, 0.92591957]}, {'shape': [2], 'data': [-0.24747862, 0.16567801]}, {'shape': [3, 3, 2, 4], 'data': [-0.94835971, -0.09864511, -0.96668335, -0.11678862, -0.0684701, 0.35297961, 0.68186505, -0.64464683, 0.60428433, -0.12843896, -0.66738358, -0.96252509, 0.11343417, -0.26810103, 0.62478478, -0.92468562, 0.12092665, -0.03926093, -0.48419303, -0.2015424, -0.59762146, 0.48302104, 0.46979752, -0.33142447, 0.6379101, 0.29292009, -0.08235647, 0.58146891, -0.95709137, 0.91108344, -0.54017656, 0.7763715, -0.0947622, 0.44968087, -0.1750356, -0.16006343, -0.98221201, 0.16236873, 0.02533719, -0.7193739, -0.83571764, -0.09914948, -0.05324984, -0.58456162, 0.81909889, -0.49005946, -0.37903645, 0.7714574, 0.16240276, 0.77738959, -0.60000374, -0.4806184, -0.84023324, -0.36447888, 0.18264885, -0.32894268, 0.36280974, -0.85252119, 0.61026127, 0.04979669, -0.15516699, -0.67961233, -0.36392683, -0.8904356, 0.90778897, 0.93174974, -0.00675755, -0.19315719, 0.34133025, 0.21591398, 0.91391035, -0.50014449]}, {'shape': [4], 'data': [-0.22277998, 0.83024662, 0.28250145, 0.80130791]}, {'shape': [3, 3, 2, 5], 'data': [-0.27431101, 0.41639419, 0.28978002, 0.01022304, 0.34676476, 0.92145893, 0.54710693, -0.00129638, 0.19458927, -0.82426229, 0.2493499, 0.75655543, -0.12101202, 0.18093875, -0.06614411, -0.29852196, -0.38870871, 0.3282147, -0.58642101, -0.56520792, -0.62072695, 0.25214419, 0.39526129, -0.70663187, -0.50887732, -0.94197461, -0.86376215, -0.19962013, 0.38461478, -0.16522164, -0.51690063, -0.41235393, 0.54507372, 0.50765358, 0.8467451, 0.04629424, -0.15811579, -0.06779732, 0.54153266, 0.79279675, 0.12512371, -0.23521379, 0.99233648, -0.96873134, 0.38834065, 0.81294911, 0.42531214, 0.70748795, 0.37904506, -0.06639092, 0.46828664, 0.26222765, -0.14356817, -0.657842, -0.33931757, 0.67349513, -0.51238876, 0.12673645, -0.36282379, -0.7854849, -0.53469439, -0.51389275, 0.44516035, 0.96014876, -0.69251264, -0.53215801, 0.20153435, -0.44840485, -0.98298993, -0.07694526, -0.56084447, 0.98282922, -0.9920926, -0.61595199, 0.07188373, 0.93036601, -0.82628808, -0.14653149, -0.5680554, -0.18559245, -0.18721343, -0.25327212, 0.83281431, -0.56255354, 0.30899534, 0.1728684, 0.2793788, 0.95304186, -0.34778857, -0.20520019]}, {'shape': [5], 'data': [-0.61365363, 0.06125112, 0.92696967, 0.98891881, 0.56922671]}, {'shape': [3, 3, 2, 4], 'data': [0.03095139, -0.85141017, -0.18593318, 0.26346445, 0.28622315, 0.1769586, 0.04569921, -0.83576401, -0.18017495, 0.48590543, 0.32518963, 0.61871889, 0.39507396, -0.69729122, -0.31938951, 0.19720934, -0.55987241, -0.41076068, 0.34353851, 0.02624718, 0.61741802, -0.5673276, 0.63342611, -0.10600528, 0.12554304, 0.23736259, -0.35898466, -0.07251388, 0.56316688, -0.10835615, -0.59623822, 0.07323061, 0.7798094, 0.54100065, -0.44095185, -0.82711082, 0.3942943, -0.98620527, 0.38693823, 0.20171038, -0.45042561, 0.69727257, -0.59988551, -0.38526687, -0.67241477, -0.96960123, 0.52578098, -0.71196724, 0.33794471, -0.77846838, -0.35593011, 0.93151092, -0.00757161, -0.51565083, -0.21402329, -0.45856714, -0.31730791, -0.04441553, 0.88208495, -0.85420179, 0.91867899, 0.07909438, -0.66512917, 0.82040738, 0.04453403, 0.21720405, 0.76404934, 0.3051056, -0.95407415, 0.05532792, -0.83626565, -0.54109659]}, {'shape': [4], 'data': [0.77041048, 0.36454704, -0.49954674, -0.66859321]}, {'shape': [1, 1, 4, 2], 'data': [0.20403495, -0.77340124, -0.46550048, -0.72451726, 0.93998706, -0.22566734, -0.90885358, 0.97179257]}, {'shape': [2], 'data': [0.35004329, 0.7476916]}, {'shape': [3, 3, 5, 3], 'data': [0.66324328, 0.19081955, -0.59506243, 0.1471951, 0.25965958, -0.93468423, 0.09420988, -0.9912427, -0.92985548, 0.72284093, 0.51787613, -0.34516821, -0.22759756, 0.57881034, 0.74886838, 0.02095912, 0.30531405, -0.89652203, -0.99999733, -0.73958489, -0.17262839, -0.75704349, -0.94976901, -0.10138756, 0.17502399, 0.00341713, 0.84848194, -0.43352148, -0.7754627, 0.12829741, -0.5942284, -0.32718333, -0.61206757, 0.55407737, 0.63286786, 0.14716237, 0.09442763, -0.89726354, 0.03603109, -0.54176573, -0.73153387, -0.43883904, 0.53650005, -0.52712959, -0.63960365, 0.64788462, 0.02788558, -0.98982571, -0.05873276, -0.16270794, -0.2697736, 0.44466103, -0.37204099, -0.36049447, -0.7188804, -0.31130617, -0.13991363, -0.15400509, -0.18990097, 0.28576171, -0.35951387, 0.87857193, 0.31612829, -0.35552096, 0.98340659, 0.71448491, -0.80203168, -0.47448898, 0.65863171, -0.94015433, 0.74561267, 0.65946224, -0.7982868, 0.45268289, -0.37717328, 0.04932861, 0.27695142, 0.95217807, 0.91134146, 0.63914379, 0.53308807, -0.69570841, -0.73948524, 0.32582537, 0.21098038, 0.82341779, 0.37426877, 0.88743135, 0.06428672, -0.67808361, -0.98622069, -0.81354166, 0.40655998, 0.55061447, 0.07171017, -0.94197688, -0.2450065, -0.78986376, 0.08595119, 0.45481341, 0.27138373, -0.12731915, -0.16921596, 0.59229912, -0.71295426, 0.3515732, 0.16512066, 0.03031404, -0.36210416, 0.96125919, 0.97749474, -0.30774686, -0.61130803, 0.05220894, 0.66024908, 0.26146115, -0.66417972, -0.11453359, -0.90508858, -0.99820897, 0.65530961, -0.70517583, 0.10765285, 0.09015885, 0.40190697, -0.91258333, 0.67823482, 0.1247552, -0.99963916, -0.58976582, -0.6098986, -0.85244031, -0.79962793, -0.11070497, -0.24660294]}, {'shape': [3], 'data': [-0.93732745, 0.36141236, 0.5734914]}], 'expected': {'shape': [8, 8, 9], 'data': [0.0, 0.0, 0.62929773, 0.0, 0.0, 0.21861774, 0.0, 2.5681355, 0.0, 1.5178237, 0.0, 0.0, 0.0, 0.3674975, 0.58978391, 0.0, 1.38366723, 0.0, 1.72466934, 0.0, 0.0, 0.55973428, 0.0, 0.21195978, 0.0, 1.6808219, 0.0, 0.01973909, 0.34776607, 0.0, 0.0, 1.03609097, 0.02541882, 0.0, 0.0, 0.0, 2.52178717, 0.0, 0.41106793, 0.0, 0.3500433, 0.74769163, 0.0, 0.0, 0.0, 1.93141079, 0.0, 0.0, 0.74543613, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.97346711, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.47774005, 0.59940797, 0.0, 0.0, 0.23312378, 0.56571496, 2.67315912, 1.0211513, 0.0, 3.42914176, 0.0, 0.0, 0.0, 0.39189905, 0.09429175, 0.0, 0.0, 0.0, 2.10040617, 0.0, 0.0, 0.0, 0.0, 0.65645677, 0.0, 0.564219, 0.0, 2.93167734, 0.0, 0.0, 0.5120067, 0.0, 0.21924347, 2.10213757, 2.62606692, 0.0, 0.01113749, 1.71983314, 2.10439324, 0.0, 0.0, 0.74068928, 0.0, 0.0, 0.0, 1.42224312, 0.0, 0.28322342, 0.38412839, 1.04991603, 0.01260114, 0.0, 0.0, 0.0, 2.2815485, 0.69245982, 0.0, 0.6871056, 0.40284127, 0.0, 0.0, 1.09891582, 0.0, 0.0, 0.09913579, 0.20608494, 0.0, 0.0, 0.14110279, 0.0, 2.10786724, 0.0, 0.005283, 0.93631291, 0.47320786, 0.70829004, 0.0, 0.12003946, 0.0, 0.0, 0.0, 0.11554015, 0.0, 1.51409125, 0.0, 0.37453014, 0.22507578, 0.0, 0.0, 0.0, 1.64961171, 0.0, 0.50767446, 0.0, 0.24067231, 0.0, 0.0, 2.82217264, 0.0, 0.73979831, 0.36891019, 0.0, 1.07717609, 0.0, 0.5752722, 0.0, 4.38589334, 0.0, 0.22729802, 1.40378618, 0.0, 0.0, 0.98281872, 0.0, 0.0, 0.0, 0.0, 0.0, 1.46709609, 0.0, 0.08484232, 1.05149436, 0.11742622, 0.0, 0.0, 0.0, 0.69135064, 0.41241601, 0.0, 0.0, 0.89727414, 0.0, 0.0, 0.0, 0.0, 1.00112224, 1.09653044, 0.0, 0.62414902, 0.84546232, 0.0, 0.0, 0.0, 0.0, 0.20333236, 0.0, 0.42324039, 0.0, 0.78969669, 0.38783786, 0.0, 1.16561103, 0.15639812, 0.0, 1.4686892, 0.0, 0.0, 0.22956428, 0.62281746, 0.0, 0.0, 0.0, 1.32129383, 2.0982728, 0.0, 0.0, 1.14511299, 0.0, 0.0, 0.0, 0.0, 1.69848061, 0.0, 0.0, 0.29939181, 0.10372044, 0.36430821, 0.20238751, 2.98216271, 0.0, 0.0, 1.73132086, 1.00148177, 0.0, 0.43124521, 0.65848732, 0.0, 0.0, 0.0, 0.01306325, 0.0, 1.8990376, 0.0, 0.95077562, 0.24734235, 0.0, 0.0, 0.0, 0.75943679, 0.0, 0.0, 0.61680323, 0.0491474, 0.0, 0.0, 1.18927217, 0.0, 2.08053231, 0.0, 0.0, 0.0, 0.17929713, 0.23237479, 0.0, 0.0, 0.0, 1.67524862, 1.37533557, 0.0, 0.0, 0.31197986, 0.60904914, 0.0, 0.0, 0.0, 0.0, 1.14475608, 0.04775193, 0.0, 0.50533789, 0.0, 0.0, 0.0, 0.0, 0.90846938, 0.51550114, 0.0, 0.13144439, 0.0, 1.84550452, 0.0, 0.66510779, 0.2291103, 2.35315323, 0.0, 0.0, 0.68876344, 1.36489654, 0.0, 1.15461254, 0.0, 0.0, 0.81690651, 1.54917479, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.66084582, 2.20051003, 0.6324904, 0.6283257, 0.0, 1.11781645, 0.40924454, 1.24133301, 0.0, 0.0, 1.96754551, 0.0, 1.6208899, 0.0, 0.11203408, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.46940199, 0.0, 0.27433753, 0.00349736, 0.0, 0.0, 1.7961452, 1.17558169, 0.2626746, 0.0, 0.84671968, 0.0, 0.16535956, 0.0, 0.0, 0.0, 0.0, 0.80041862, 0.65415466, 0.0, 0.46961302, 0.71898592, 0.0, 0.0, 0.0, 0.28701162, 0.0, 2.11897349, 0.0, 1.25467491, 0.0, 0.0, 0.0, 0.0, 1.86730075, 0.0, 0.0, 0.49702615, 0.21134606, 0.67347211, 0.0, 0.0, 0.74047989, 0.0, 1.19012833, 0.0, 0.0, 0.70699859, 0.0, 0.0, 0.0, 0.0, 0.84572166, 1.37336707, 0.0, 1.75503087, 0.0, 0.42757723, 0.0, 0.0, 0.0, 0.38296205, 1.0989486, 0.0, 0.0, 0.02495798, 0.0, 0.0, 0.0, 0.0, 1.9974699, 0.0, 0.0, 0.0, 1.6543504, 0.0, 0.0, 0.0, 0.0, 1.59850907, 0.0, 0.0, 0.0, 1.04718494, 0.32916346, 0.0, 0.0, 0.0, 0.0, 1.40552521, 0.0, 0.0, 0.21601687, 0.11928326, 0.0, 0.0, 0.0, 1.2392019, 0.6590929, 0.0, 0.0, 0.0, 0.6891827, 0.0, 0.0, 0.0, 2.28519392, 0.97152948, 0.0, 0.0, 0.87898934, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.15249491, 0.5550431, 0.0, 0.0, 0.0, 1.00976872, 2.03569293, 0.06326869, 0.47870892, 0.00997627, 0.0, 0.04953283, 0.0, 0.0, 0.0, 0.01819345, 0.0, 0.0, 0.0, 1.16732931, 0.0, 0.0, 0.0, 2.58225513, 0.08062008, 0.03519639, 1.31689477, 0.20114276, 0.38546491, 0.0, 0.0, 0.0, 0.87664527, 0.0, 0.0, 0.0, 0.08017206, 0.0, 0.18043941, 0.0, 0.0, 0.0, 0.0, 0.33421621, 0.0, 1.2028482, 0.07765001, 0.0, 0.0, 1.98943448, 0.0, 0.48974594, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.74752092, 0.03910804, 0.0, 0.0, 0.0, 0.9813568, 0.0, 0.0, 0.28072649, 0.52664822, 0.07893914, 0.0, 0.0, 0.13949138, 0.0, 0.0, 2.54865003, 0.0, 1.13503933, 0.0, 0.0, 0.0, 0.0, 0.20768833, 0.0, 2.27561259, 3.04414296, 1.39914989, 0.43852368, 0.10387513, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.11025637, 0.0, 0.0, 0.3165223, 0.53895682, 0.0, 0.0, 0.0, 0.04426211, 1.8920238, 0.0, 0.0, 0.0, 1.09175754, 0.0, 0.0, 0.0, 0.0]}, 'inputs': [{'shape': [8, 8, 2], 'data': [-0.71596766, 0.83019575, 0.12233745, 0.92591957, -0.7441074, 0.91311007, 0.57807094, -0.03576367, 0.92920752, 0.6086378, -0.48492931, 0.7050366, -0.2138371, -0.47310562, 0.87291123, 0.8320452, 0.71154974, 0.6595046, 0.28165745, 0.38950711, 0.07524211, 0.33454801, -0.03415678, -0.52388923, 0.47638866, 0.37107957, -0.54665296, -0.87224887, -0.13100523, -0.90434305, -0.69297542, -0.20749719, -0.56915713, 0.78840033, 0.4726286, -0.36316651, -0.76725236, 0.07194024, 0.72501587, -0.44661986, 0.34143365, -0.68083833, 0.5516467, 0.76098341, -0.65435454, -0.34955562, 0.35460557, 0.74500127, 0.22412019, -0.8949028, 0.91785351, -0.08805319, 0.30409744, 0.22871151, 0.64410713, -0.33868946, -0.29857075, 0.64194591, -0.11058409, 0.67525571, -0.55152819, 0.95742989, 0.32230099, -0.37273314, 0.5853308, -0.07263406, 0.85342309, 0.64604714, 0.06354282, 0.35724061, 0.48552468, -0.61698594, 0.90320587, -0.00590762, -0.13276388, -0.14733, -0.94865827, 0.4789463, -0.9931224, 0.24979199, -0.02533708, -0.91660384, 0.28220661, 0.49672527, 0.15421375, 0.46070124, -0.82461467, -0.86675734, 0.06245427, -0.20912924, 0.21296295, -0.65097442, 0.48605866, -0.42302779, -0.1352, 0.7276669, -0.54014337, -0.26808048, 0.97774798, -0.04839242, 0.378259, -0.24514065, 0.18595675, 0.16405805, 0.00832465, 0.68356762, 0.95055944, 0.02838399, 0.71627281, 0.86495896, -0.28564114, 0.12227878, -0.06468315, 0.71635096, 0.06627862, 0.67062676, 0.99457316, 0.77844231, -0.24861469, -0.81501619, 0.4882452, 0.68723879, 0.32517313, -0.80750622, -0.60951189, 0.29473096, 0.86109569, -0.02245938]}, {'shape': [8, 8, 2], 'data': [-0.24747862, 0.16567801, -0.72708636, -0.51203095, -0.65120245, -0.3427661, 0.19812908, -0.41912825, 0.51400774, 0.84804922, 0.91944686, 0.38582885, -0.80457858, -0.3099973, -0.92714059, -0.71400301, 0.39199149, 0.00699257, -0.93688666, -0.58961411, -0.04144213, 0.18229065, -0.77147876, -0.916298, 0.96939102, 0.86129989, 0.03954671, 0.14192202, -0.52413311, -0.20872022, 0.80721014, 0.51425215, -0.71327573, -0.57193911, -0.43415532, 0.32773007, -0.20031805, -0.83197124, -0.68893263, 0.05999622, 0.72426418, 0.41552996, -0.25334752, -0.48358383, 0.50249671, -0.91499205, -0.69306111, -0.72922734, -0.27360866, -0.81560465, 0.3917528, -0.28981351, 0.5060341, -0.634636, -0.09391956, -0.22843226, -0.08124607, 0.95052656, -0.91621963, 0.66031604, -0.65365584, 0.05314522, 0.88424331, -0.31617149, 0.94410572, -0.17168922, -0.25377721, -0.67768744, 0.96338789, 0.10442256, -0.40672325, 0.6249184, -0.72385146, -0.89999819, -0.5040491, -0.76177713, 0.10358107, 0.59052122, -0.16553679, 0.77533011, -0.0719829, -0.99221325, 0.67404539, -0.40043528, -0.2030353, 0.06771592, 0.98988664, 0.38263504, -0.83934287, 0.5554961, -0.11620085, -0.58278228, 0.96764707, -0.81884064, -0.26389177, 0.95331379, 0.9739489, 0.47562164, -0.1416172, -0.95291247, -0.5806753, -0.6637242, 0.71157748, -0.50035731, -0.65895323, 0.65297285, -0.42407917, -0.25404049, 0.25810519, 0.20944389, 0.52969914, 0.54656459, 0.2705085, 0.27974111, -0.25302568, -0.44249543, 0.44846675, -0.6585746, -0.57279857, 0.82091076, -0.06622698, -0.22816221, -0.70184731, 0.35015931, -0.83494154, 0.60686221, -0.50241969, 0.54023812]}, {'shape': [8, 8, 2], 'data': [-0.94835971, -0.09864511, -0.96668335, -0.11678862, -0.0684701, 0.35297961, 0.68186505, -0.64464683, 0.60428433, -0.12843896, -0.66738358, -0.96252509, 0.11343417, -0.26810103, 0.62478478, -0.92468562, 0.12092665, -0.03926093, -0.48419303, -0.2015424, -0.59762146, 0.48302104, 0.46979752, -0.33142447, 0.6379101, 0.29292009, -0.08235647, 0.58146891, -0.95709137, 0.91108344, -0.54017656, 0.7763715, -0.0947622, 0.44968087, -0.1750356, -0.16006343, -0.98221201, 0.16236873, 0.02533719, -0.7193739, -0.83571764, -0.09914948, -0.05324984, -0.58456162, 0.81909889, -0.49005946, -0.37903645, 0.7714574, 0.16240276, 0.77738959, -0.60000374, -0.4806184, -0.84023324, -0.36447888, 0.18264885, -0.32894268, 0.36280974, -0.85252119, 0.61026127, 0.04979669, -0.15516699, -0.67961233, -0.36392683, -0.8904356, 0.90778897, 0.93174974, -0.00675755, -0.19315719, 0.34133025, 0.21591398, 0.91391035, -0.50014449, -0.92084809, -0.35801941, 0.92646965, 0.63906244, -0.7862314, -0.97338327, -0.53248659, 0.77039418, -0.21462975, -0.33860877, 0.55072188, 0.76482394, 0.03265566, -0.77091635, -0.93693592, 0.38717905, 0.31201908, 0.78539249, 0.61142735, 0.4949996, -0.33130496, 0.47453938, -0.24013018, 0.65542996, -0.38177205, -0.72255081, 0.98157082, -0.04956913, -0.51364003, -0.09737185, -0.67956277, -0.12264863, -0.81807845, 0.27796378, -0.86354697, -0.02549271, -0.73233606, 0.78969285, 0.05405403, 0.85786743, 0.50773876, -0.68577323, -0.80660061, -0.04535169, -0.33548031, 0.36352017, 0.71201384, 0.26114917, -0.94406802, 0.14021468, 0.19291905, -0.59873092, -0.93175345, -0.35538796, 0.84528125, 0.9069683]}]}\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (8, 8, 2)\n",
    "\n",
    "input_layer_0 = Input(shape=data_in_shape)\n",
    "branch_0 = Conv2D(4, 3, 3, activation='relu', border_mode='same', subsample=(1, 1), dim_ordering='tf', bias=True,\n",
    "                         name='conv_0-0')(input_layer_0)\n",
    "\n",
    "input_layer_1 = Input(shape=data_in_shape)\n",
    "branch_1 = Conv2D(2, 1, 1, activation='relu', border_mode='valid', subsample=(1, 1), dim_ordering='tf', bias=True,\n",
    "                         name='conv_1-0')(input_layer_1)\n",
    "branch_1 = Conv2D(4, 3, 3, activation='relu', border_mode='same', subsample=(1, 1), dim_ordering='tf', bias=True,\n",
    "                         name='conv_1-1')(branch_1)\n",
    "branch_1 = Conv2D(2, 1, 1, activation='relu', border_mode='valid', subsample=(1, 1), dim_ordering='tf', bias=True,\n",
    "                         name='conv_1-2')(branch_1)\n",
    "\n",
    "input_layer_2 = Input(shape=data_in_shape)\n",
    "branch_2 = Conv2D(5, 3, 3, activation='relu', border_mode='same', subsample=(1, 1), dim_ordering='tf', bias=True,\n",
    "                         name='conv_2-0')(input_layer_2)\n",
    "branch_2 = Conv2D(3, 3, 3, activation='relu', border_mode='same', subsample=(1, 1), dim_ordering='tf', bias=True,\n",
    "                         name='conv_2-1')(branch_2)\n",
    "\n",
    "output_layer = merge([branch_0, branch_1, branch_2], mode='concat')\n",
    "model = Model(input=[input_layer_0, input_layer_1, input_layer_2], output=output_layer)\n",
    "\n",
    "data_in = []\n",
    "for i in range(3):\n",
    "    np.random.seed(19000 + i)\n",
    "    data_in.append(np.expand_dims(2 * np.random.random(data_in_shape) - 1, axis=0))\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "weights = []\n",
    "for i, w in enumerate(model.get_weights()):\n",
    "    np.random.seed(19000 + i)\n",
    "    weights.append(2 * np.random.random(w.shape) - 1)\n",
    "model.set_weights(weights)\n",
    "\n",
    "result = model.predict(data_in)\n",
    "\n",
    "print({\n",
    "    'inputs': [{'data': format_decimal(data_in[i].ravel().tolist()), 'shape': list(data_in_shape)} for i in range(3)],\n",
    "    'weights': [{'data': format_decimal(weights[i].ravel().tolist()), 'shape': list(weights[i].shape)} for i in range(len(weights))],\n",
    "    'expected': {'data': format_decimal(result[0].ravel().tolist()), 'shape': list(result[0].shape)}\n",
    "})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['input_5', 'conv_1-0', 'input_6', 'input_4', 'conv_1-1', 'conv_2-0', 'conv_0-0', 'conv_1-2', 'conv_2-1', 'merge_2']\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "config = json.loads(model.to_json())\n",
    "print([x['config']['name'] for x in config['config']['layers']])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
